package com.baidu.sggc.core.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * swagger访问地址 http://localhost:8008/swagger-ui/index.html
 * swagger访问地址 http://localhost:8008/doc.html
 */
@Configuration
public class OpenApiConfig {

  @Bean
  public OpenAPI openApi() {
    return new OpenAPI()
        .info(new Info().title("知识引擎接口文档").version("v1.0"))
        .components(new Components()
            .addSecuritySchemes("SecretHeader", new SecurityScheme()
                .type(SecurityScheme.Type.APIKEY)
                .in(SecurityScheme.In.HEADER)
                .name("x-test-user")))
        .addSecurityItem(new SecurityRequirement().addList("SecretHeader"));
  }

}

